//
//  CRResetOldPWDView.m
//  CRChatRoom
//
//  Created by CuiFengshuai on 15/11/26.
//  Copyright © 2015年 SecondGroup. All rights reserved.
//

#import "CRResetOldPWDView.h"
#import "CRUserManager.h"

@interface CRResetOldPWDView ()

@property (nonatomic, strong) CRUserManager *manager;

@end

@implementation CRResetOldPWDView
#pragma mark >>>>懒加载

- (CRUserManager *)manager {
    if (!_manager) {
        _manager = [CRUserManager new];
    }
    return _manager;
}

+ (instancetype)resetPasswordByOldPassword {
    return [[[NSBundle mainBundle] loadNibNamed:@"CRResetOldPWDView" owner:nil options:nil] lastObject];
    
}

- (void)resetPasswordByOldPwd {
    // 判断两次输入的密码是否一致
    if (![self.setNewPwdText.text isEqualToString:self.tureNewPwdText.text]) {
        NSLog(@"两次输入不一致");
        
        return;
    }
    [self.resetPwdButton addTarget:self action:@selector(didClickResetPwdButton:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark >>>> 按钮点击事件监听方法
- (void)didClickResetPwdButton:(UIButton *)button {
    // 修改密码
    [self.manager updatePasswordWithOldpwd:self.oldPwdText.text newPwd:self.setNewPwdText.text success:^{
        NSLog(@"修改成功");
    } failure:^(NSError *error) {
        NSLog(@"修改失败");
    }];
}
@end
